package com.xinchuang.controller.targetSystem.configure;

import com.xinchuang.comment.R;
import com.xinchuang.common.Result;
import com.xinchuang.entity.targetSystem.system.TargetSubType;
import com.xinchuang.service.targetSystem.TargetSubTypeService;
import io.swagger.annotations.Api;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * TODO
 *
 * @author zkwczx
 * @version 1.0
 * @date 2023/11/7 19:53
 */
@RequestMapping(value = "/subType")
@RestController
@RequiredArgsConstructor
@Api(value = "子目标类型", tags = {"子目标类型"})
public class TargetSubTypeController {

    private static final String delSubType = "/delSubType";

    private final TargetSubTypeService targetSubTypeService;

    @PostMapping(value = delSubType)
    public Result addSubType(@RequestBody TargetSubType targetSubType) {
        return targetSubTypeService.addSubType(targetSubType);
    }

    @PutMapping(value = delSubType)
    public Result updateSubType(@RequestBody TargetSubType targetSubType) {
        return targetSubTypeService.updateSubType(targetSubType);
    }

    @DeleteMapping(value = delSubType)
    public Result deleteSubType(@RequestParam(value = "typeId") String typeId) {
        return targetSubTypeService.deleteSubType(typeId);
    }

    @GetMapping(value = delSubType)
    public Result selectSubType(@RequestParam(value = "parentId") String parentId) {
        return targetSubTypeService.getType(parentId);
    }

}
